<?php

$app->get('/:language/application/info', 'getApplicationInfo');

function getApplicationInfo($language) {	
	$info = array();
	$info['version'] = getApplicationVersion();
	$info['pictureCount'] = getPictureCount($language);
	$info['supportedLanguages'] = getSupportedLanguagesArray();
	echo json_encode($info);
}

function getApplicationVersion() {	
    return "1.0.9";
}

function getPictureCount($language) {	
	$sqlQuery = "SELECT COUNT(*) as count FROM ".TABLE_PICTURE;
	if ($language != null)
		$sqlQuery = $sqlQuery." WHERE correctAnswers_$language IS NOT NULL AND correctAnswers_$language <> ''";
	$sql = createQuery($sqlQuery); 
	return mysqli_fetch_object($sql)->count;
}

function getSupportedLanguages() {	
	echo json_encode(getSupportedLanguagesArray()); 
}

function getSupportedLanguagesArray() {	
	return array('de', 'en'); 
}
	
?>
